#!/bin/bash

set -ux

nodes=$(kubectl get no | awk '{print $1}' | grep -v 'NAME')

for node in $nodes; do
  kubectl drain $node --delete-emptydir-data --force --ignore-daemonsets
done

kubeadm reset

rm -rf ~/.kube/

# # 重置 iptables 规则
# iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X

# 重置 IPVS 表
ipvsadm -C

# 删除节点
kubectl delete node --all
